//
//  VisitListCell.m
//  YunGui
//
//  Created by wmm on 15/11/14.
//  Copyright © 2015年 hanen. All rights reserved.
//

#import "VisitListCell.h"
#import "VisitModel.h"

#define LeftWidth [UIView getWidth:20.0f]
#define LabelHeight 20.0f

@implementation VisitListCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        self.clipsToBounds = YES;
        
        //选中单元格
//        UIView *bgView = [[UIView alloc] init];
//        bgView.backgroundColor = [UIColor colorWithRed:(20.0f/255.0f) green:(30.0f/255.0f) blue:(40.0f/255.0f) alpha:0.5f];
//        self.selectedBackgroundView = bgView;
        CGFloat lineW = 3.0f;
        
        UIView *leftLine1 = [[UIView alloc] initWithFrame:CGRectMake(LeftWidth, 0.0f, lineW, 10.0f)];
        leftLine1.backgroundColor = LEFTLINECOLOR;
        
        UIImageView *quanImg = [[UIImageView alloc] initWithFrame:CGRectMake(LeftWidth-6.0f, leftLine1.maxY+lineW,15.0f, 15.0f)];
        quanImg.image = [UIImage imageNamed:@"Btn_Normal_Shijianquan.png"];

        UIView *leftLine2 = [[UIView alloc] initWithFrame:CGRectMake(LeftWidth, quanImg.maxY+lineW, lineW, 95.0-quanImg.maxY-lineW)];
        leftLine2.backgroundColor = LEFTLINECOLOR;
        
        CGRect visitNumFrame = CGRectMake(leftLine2.maxX+15.0f, leftLine1.maxY+2.0f, kScreenWidth-leftLine2.maxX-LabelHeight, LabelHeight);
        self.visitNum = [[UILabel alloc] initWithFrame:visitNumFrame];
        self.visitNum.font = [ViewTool getFont:14.0f];
        self.visitNum.textColor = BLACKCOLOR;
        
        
        
        
        CGRect visitSubFrame = CGRectMake(self.visitNum.x, self.visitNum.maxY+5.0f, self.visitNum.width, LabelHeight);
        self.visitSub = [[UILabel alloc] initWithFrame:visitSubFrame];
        
        self.visitSub.font = [ViewTool getFont:15.0f];
        self.visitSub.textColor = BLACKCOLOR;
        
//        UIImageView *proImg = [[UIImageView alloc] initWithFrame:CGRectMake(self.visitNum.x, self.visitSub.maxY+8.0f, LabelHeight, LabelHeight)];
//        proImg.image = [UIImage imageNamed:@"Btn_Normal_AiXin.png"];
        
        self.dateImage = [[UIImageView alloc] initWithFrame:CGRectMake(self.visitNum.x, self.visitSub.maxY+8.0f, LabelHeight, LabelHeight)];
        self.dateImage.image = [UIImage imageNamed:@"Btn_Normal_AiXin.png"];
        
        CGFloat W = [@"2015-05-13 19:02:25" boundingRectWithSize:CGSizeMake(MAXFLOAT, self.visitDate.height) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [ViewTool getFont:13.0f],NSForegroundColorAttributeName : GRAYCOLOR2} context:nil].size.width;
        
        CGFloat w2 = kScreenWidth-W-10.0f-LabelHeight-self.dateImage.maxX;
        
        CGRect visitProFrame = CGRectMake(self.dateImage.maxX+5.0f,self.dateImage.y+2.0f, w2, LabelHeight);
        self.visitPro = [[UILabel alloc] initWithFrame:visitProFrame];
        self.visitPro.font = [ViewTool getFont:13.0f];
        self.visitPro.textColor = GRAYCOLOR;
        
        self.payImage = [[UIImageView alloc] initWithFrame:CGRectMake(self.visitPro.maxX,self.dateImage.y,LabelHeight, LabelHeight)];
        self.payImage.image = [UIImage imageNamed:@"Btn_Normal_Shijian.png"];
        
        CGRect visitDateFrame = CGRectMake(self.payImage.maxX + 5, self.dateImage.y+1.0f, W+5.0f, LabelHeight);
        self.visitDate = [[UILabel alloc] initWithFrame:visitDateFrame];
        self.visitDate.font = [ViewTool getFont:13.0f];
        self.visitDate.textColor = GRAYCOLOR2;
//        self.visitDate.textAlignment=NSTextAlignmentRight;
        self.visitDate.text = @"2015-05-13 19:02:25";
        
        
        
//        self.visitDate.width = W;
//        self.visitDate.x = kScreenWidth-W-5.0f;
//        self.visitDate.frame = frame;
//        CGRect frame = cell.companyLevelImage.frame;
//        cell.companyLevelImage.frame = CGRectMake(W + 20, frame.origin.y, frame.size.width, frame.size.height);

        UIView *bottomLine = [ViewTool getLineViewWith:CGRectMake(visitNumFrame.origin.x, 95.0-1.0f, kScreenWidth-self.visitNum.x, 1.0f) withBackgroudColor:LEFTLINECOLOR];

        [self.contentView addSubview:leftLine1];
        [self.contentView addSubview:quanImg];
        [self.contentView addSubview:leftLine2];
        
        [self.contentView addSubview:self.visitNum];
        [self.contentView addSubview:self.visitSub];
        [self.contentView addSubview:self.dateImage];
        [self.contentView addSubview:self.visitPro];
        [self.contentView addSubview:self.visitDate];
        [self.contentView addSubview:self.payImage];
        [self.contentView addSubview:bottomLine];

    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}


@end
